home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 4.1 KB | 152 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRGrUtil.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef PRGRUTIL_H
- #include "PRGrUtil.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphx_PrivateGrUtil
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacGetPortTextStyle
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMacGetPortTextStyle(TextStyle& theTextStyle)
- {
- GrafPtr curPort = FW_QDGlobals.thePort;
- theTextStyle.tsFont = curPort->txFont;
- theTextStyle.tsFace = curPort->txFace;
- theTextStyle.tsSize = curPort->txSize;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacSetPortTextStyle
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMacSetPortTextStyle(const TextStyle& theTextStyle)
- {
- ::TextFont(theTextStyle.tsFont);
- ::TextFace(theTextStyle.tsFace);
- ::TextSize(theTextStyle.tsSize);
- }
- #endif
-
- #ifdef FW_BUILD_WIN
-
- //----------------------------------------------------------------------------------------
- // FW_WinPrivGetDisplayColorInfo
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivWinGetDisplayColorInfo(short& planeCount, short& bitsPixel)
- {
- static short gPlaneCount = -1;
- static short gBitsPixel = -1;
-
- if(gPlaneCount == -1)
- {
- HDC hDC = ::GetDC(NULL);
- gPlaneCount = (short) ::GetDeviceCaps(hDC, PLANES);
- gBitsPixel = (short) ::GetDeviceCaps(hDC, BITSPIXEL);
- ::ReleaseDC(NULL, hDC);
- }
-
- planeCount = gPlaneCount;
- bitsPixel = gBitsPixel;
- }
-
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_PrivCalcArcPoints
- //----------------------------------------------------------------------------------------
- // [KVV] Need to be changed. Could do better than that.
-
- void SL_API FW_PrivCalcArcPoints(const FW_CPlatformRect& rect,
- short angle,
- FW_CPlatformPoint& arcPoint)
- {
- if (angle >= 360)
- angle = angle % 360;
- else if(angle < 0)
- angle = (angle % 360) + 360;
-
- FW_PlatformCoordinate middleX = (rect.right + rect.left) / 2;
- FW_PlatformCoordinate middleY = (rect.right + rect.left) / 2;
- const FW_Fixed halfX = FW_IntToFixed((rect.right - rect.left) / 2);
- const FW_Fixed halfY = FW_IntToFixed((rect.bottom - rect.top) / 2);
-
- switch (angle)
- {
- case 0:
- arcPoint.Set(middleX, rect.top);
- break;
- case 45:
- arcPoint.Set(rect.right, rect.top);
- break;
- case 90:
- arcPoint.Set(rect.right, middleY);
- break;
- case 135:
- arcPoint.Set(rect.right, rect.bottom);
- break;
- case 180:
- arcPoint.Set(middleX, rect.bottom);
- break;
- case 225:
- arcPoint.Set(rect.left, rect.bottom);
- break;
- case 270:
- arcPoint.Set(rect.left, middleY);
- break;
- case 315:
- arcPoint.Set(rect.left, rect.top);
- break;
-
- default:
- FW_Fixed fxRad = (FW_IntToFixed(90 - angle) * FW_kFixedPI) / FW_IntToFixed(180);
- if (angle < 45)
- arcPoint.Set(FW_FixedToInt(halfX * FW_Cos(fxRad)) + middleX, rect.top);
- else if (angle > 45 && angle < 135)
- arcPoint.Set(rect.right, FW_FixedToInt(halfY * FW_Sin(fxRad)) + middleY);
- else if (angle < 180)
- arcPoint.Set(FW_FixedToInt(halfX * FW_Cos(fxRad)) + middleX, rect.bottom);
- else
- {
- fxRad = (FW_IntToFixed(angle - 270) * FW_kFixedPI) / FW_IntToFixed(180);
- if (angle < 45)
- arcPoint.Set(middleX - FW_FixedToInt(halfX * FW_Cos(fxRad)), rect.top);
- else if (angle > 45 && angle < 135)
- arcPoint.Set(rect.right, middleY - FW_FixedToInt(halfY * FW_Sin(fxRad)));
- else if (angle < 180)
- arcPoint.Set(middleX - FW_FixedToInt(halfX * FW_Cos(fxRad)), rect.bottom);
- }
- break;
- }
- }
-
-